<template>
  <div class="detail_box">
    <div class="table_box">
      <el-table
        border
        v-loading="loading"
        :header-cell-style="tableHeader"
        ref="multipleTable"
        :data="tableInfo"
        tooltip-effect="dark"
        style="width: 100%;">
        <el-table-column
          width="85"
          prop="recordCode"
          label="ID">
        </el-table-column>
        <el-table-column
          label="上报内容">
          <template slot-scope="scope">
            <span>{{ scope.row.content ? scope.row.content : '——' }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="startTime"
          sortable
          label="故障发生时间">
        </el-table-column>
        <el-table-column
          label="是否解决">
          <template slot-scope="scope">
            <span :style="'color:'+(scope.row.isrepair?'#63d863':'#e40000')">{{ scope.row.isrepair ? '是' : '否' }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="repairTime"
          sortable
          label="故障修复时间">
          <template slot-scope="scope">
            <span>{{ scope.row.repairTime ? scope.row.repairTime : '——' }}</span>
          </template>
        </el-table-column>
        <!--        <el-table-column-->
        <!--          label="是否现场解决">-->
        <!--          <template slot-scope="scope">-->
        <!--            <span :style="'color:'+(scope.row.localSolution?'green':'#e40000')">{{scope.row.localSolution?'是':'否'}}</span>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <el-table-column
          label="是否自动上报">
          <template slot-scope="scope">
            <span
              :style="'color:'+(scope.row.autoStatus?'#63d863':'#e40000')">{{ scope.row.autoStatus ? '是' : '否' }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="record_page">
      <span class="page_count">共<i>{{ totals }}</i>条</span>
      <el-pagination
        @size-change="sizeChange"
        @current-change="getTableInfo"
        background
        :current-page="currentPage"
        :page-sizes="[15, 20, 30, 40]"
        :page-size="pageSize"
        layout="prev, pager, next, sizes,jumper"
        :total="totals">
      </el-pagination>
    </div>
  </div>
</template>

<script>

import {getFireFaultEvent} from "../../../api/faultEvent";

export default {
  data() {
    return {
      tableInfo: [],
      currentPage: 1,
      pageSize: 15,
      totals: 0,
      loading: false,
    }
  },
  mounted() {
    this.getTableInfo(1)
  },
  methods: {
    // 获取列表信息
    getTableInfo(page) {
      let that = this;
      that.loading = true;
      that.currentPage = page;
      let queryParams = {
        limit: that.pageSize,
        page: page
      }
      getFireFaultEvent(queryParams).then(res => {
        that.totals = res.data ? res.data.count : 0;
        that.tableInfo = res.data ? res.data.list : [];
        that.loading = false;
      }, (err) => {
        that.loading = false;
      });
    },

    sizeChange(val) {
      this.pageSize = val;
      this.getTableInfo(1)
    },

    // 设置table标题居中
    tableHeader({row, column, rowIndex, columnIndex}) {
      return 'background:#F0F2F5;color:#111;padding:10px 0;font-size:14px;font-weight:600'
    },
  }
}
</script>

<style scoped>

</style>
